package com.linkoog.devtools.toolwindow_manager;

import com.intellij.CommonBundle;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.PropertyKey;

import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
import java.util.ResourceBundle;

/**
 */
class ToolWindowManagerBundle {
    private static Reference<ResourceBundle> ourBundle = null;

    @NonNls
    private static final String BUNDLE = "ToolWindowManagerBundle";

    private static ResourceBundle getBundle() {
        ResourceBundle bundle = null;

        if (ourBundle != null) {
            bundle = ourBundle.get();
        }

        if (bundle == null) {
            bundle = ResourceBundle.getBundle(BUNDLE);
            ourBundle = new SoftReference<ResourceBundle>(bundle);
        }

        return bundle;
    }

    static String message(@PropertyKey(resourceBundle = BUNDLE) final String key, final Object... params) {
        return CommonBundle.message(getBundle(), key, params);
    }

    private ToolWindowManagerBundle() {
    }
}
